<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>

<%@ page include file="inc.jsp>" %>
<%
	String drv = "com.mysql.jdbc.Driver";
	String url = "jdbc:mysql://localhost:3306/demo";
	String usr = "root";
	String pwd = "root";

	String sql = "select * from user";
	try {
		Class.forName(drv).newInstance();
		Connection conn = DriverManager.getConnection(url, usr, pwd);
		//PreparedStatement ppst =conn.prepareStatement(sql);
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery(sql);
		ResultSetMetaData rsmd = rs.getMetaData();
		int cols = rsmd.getColumnCount();
		

		while (rs.next()) {
			for (int i = 1; i <= cols; i++) {
				String field = (String) (rsmd.getColumnName(i));
				String value = (String) (rs.getString(i));

				out.print(field + "=" + value + ";");
				
			}
		}

	} catch (Exception e) {
		e.printStackTrace();
		out.println(e);
	}
%>
